#include<bits/stdc++.h>
using namespace std;

struct node
{
	string name, el;
	int year, month, day;
	bool operator < (const node &a) const
	{
		if(year != a.year)
			return year < a.year;
		else if(month != a.month)
			return month < a.month;
		else
			return day < a.day;
	}
}f[100];

int main()
{
	int n;
	cin>>n;
	for(int i = 1;i <= n;i++)
		cin>>f[i].name>>f[i].year>>f[i].month>>f[i].day>>f[i].el;
	sort(f+1, f+n+1);
	cout<<"name year month day el"<<endl;
	for(int i = 1;i <= n;i++)
		cout<<f[i].name<<" "<<f[i].year<<" "<<f[i].month<<" "<<f[i].day<<" "<<f[i].el<<endl; 
	return 0;
}

